package com.dragonsky.shop.user.controller;

import com.dragonsky.shop.common.utils.AjaxResult;
import com.dragonsky.shop.dubbo.product.service.ProductDubboService;
import com.dragonsky.shop.dubbo.user.service.UserDubboService;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/userDubbo")
public class UserDubboController {

    @DubboReference
    private UserDubboService userDubboService;

    @DubboReference
    private ProductDubboService productDubboService;


    @GetMapping("/userName")
    public AjaxResult<String> userName(@RequestParam(value = "userId", required = false) Long userId) {
        String userName = productDubboService.productName(userId);
        System.out.printf("userName:%s\n", userName);
        return AjaxResult.succeedWith(userName);
    }

}
